program WtTracker;

uses
  Forms,
  SysUtils,
  Windows,
  TrackerMainUnit in 'TrackerMainUnit.pas' {frmTracker},
  ProtocolUnit in '..\..\ProtocolUnit.pas',
  ConstUnit in '..\..\ConstUnit.pas',
  FunctionUnit in '..\..\FunctionUnit.pas';

{$R *.res}

var
  pId: DWORD;
  hMutex: THandle;

begin
//  pId := GetCurrentProcessId;
//  FindAndKillProcess(ExtractFileName(Application.ExeName), pId);
//  Sleep(800);

//  RegisterDll := ExtractFilePath(ParamStr(0)) + 'gu\bs.key';
  hMutex := CreateMutex(nil, False, PChar(WtTrackerMutext));

  try
    if GetLastError = ERROR_ALREADY_EXISTS then
      Exit;

    if not Boolean(StrToIntDef(GetRegisterDllValue(RegisterDll, KEY_USER_TYPE), 0)) then
      Exit;

    Application.Initialize;
    Application.CreateForm(TfrmTracker, frmTracker);
    Application.Run;
  finally
    CloseHandle(hMutex);
  end;
end.
